import request from "@/utils/request";
import { useDataStore } from "@/store/index.js"; // 引入 Pinia Store

// 分页查询项目列表
export function projectList(data) {
  return request({
    url: `/sp/project/list`, // 在路径中动态添加 code 参数
    headers: {
      isToken: false,
    },
    method: "get",
    params: data,
  });
}
// 分页主持人查询项目列表
export function judgeprojectList(data) {
  return request({
    url: `/mc/project/list`, // 在路径中动态添加 code 参数
    method: "get",
    params: data,
  });
}

// 查询我的评委列表
export function MyJudgeList(params) {
  console.log(params);

  return request({
    url: `/mc/project/selectMcProject`,
    method: "get",
    params: params,
  });
}

export function myJudgeList(params) {
  return request({
    url: `/mc/project/mcProject?userId=${params.userId}&status=${params.status}`,
    method: "get",
  });
}

//查询我的项目
export function myProjectInfo(data) {
  return request({
    url: `/sp/project/myApplyProject`, // 在路径中动态添加 code 参数
    method: "get",
    params: data,
  });
}

//查询主持人项目详情
export function judgeProjectInfo(data) {
  return request({
    url: `/mc/project/projectInfoAndSupplierAndJudge`, // 在路径中动态添加 code 参数
    method: "get",
    params: data,
  });
}
//查询我参与的项目
export function myChooseProject(data) {
  return request({
    url: `/sp/project/myApplyProject`,
    method: "get",
    params: data,
  });
}

//查询我中选的项目
export function myWinProject(data) {
  return request({
    url: `/sp/project/myWinProject`,
    method: "get",
    params: data,
  });
}
//根据项目批量查询供应商上传参数
export function applySupplierInfo(projectId) {
  return request({
    url: `/sp/project/applySupplierInfoByProjectId/${projectId}`,
    method: "get",
  });
}
//获取项目报名的供应商
export function applySupplierListForProject(data) {
  return request({
    url: `/sp/project/projectInfoAndSupplierAndJudge`,
    method: "get",
    params: data,
  });
}
//取消报名
export function cancelApply(id) {
  return request({
    url: `/sp/applySupplier/${id}`,
    method: "delete",
  });
}
//修改密码前 -- 验证账号
export function validateAccount(data, code) {
  return request({
    url: `/sp/SpLogin/checkSupplier?code=${code}&uuid=${data.uuid}`,
    method: "post",
    data: data,
  });
}
//验证后修改密码
export function updatePassword(data, code, uuid) {
  return request({
    url: `/sp/SpLogin/updatePassword?code=${code}&uuid=${uuid}`,
    method: "put",
    data: data,
  });
}
//添加供应商下载记录
export function addDownloadRecord(data) {
  return request({
    url: `/sp/record`,
    method: "post",
    data: data,
  });
}

//添加供应商下载记录
export function projectAttachmentDownload(data) {
  return request({
    url: `/common/projectAttachmentDownload?projectId=${data.projectId}`,
    method: "get",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    responseType: 'blob',
    data: data,
  });
}
